package com.attilax.lang;

import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.Set;

import org.apache.commons.collections.SetUtils;

import com.attilax.json.AtiJson;
import com.attilax.lang.text.strUtil;
import com.google.gson.Gson;

public class MapX {
	
	public static void main(String[] args) {
		System.out.println(getKeysStr(new HashMap(){{
			
			
		 this.put("za", "vv");
		 this.put("bc", "vv");
		}})); 
	}
	

	public static Map newMap() {
		// TODO Auto-generated method stub
		return new HashMap();
	}

	public static Map newOrderMap() {
		// TODO Auto-generated method stub
		return new LinkedHashMap();
	}

 

	public static void put_safe(Map m, String k, String[] a, int i) {
	try {
		m.put(k, a[i]);
	} catch (Exception e) {
		// TODO: handle exception
	}
		
	}

	public static int get(Map m, String nam, int i) {
		try {
			Integer it=(Integer) m.get(nam);
			if(it==null)
				return i;
			else
				return  (Integer) m.get(nam);
		} catch (Exception e) {
			return i;
		}
		 
		
	}

	public static String getKeysStr(Map map) {
	Set st=	map.keySet();
	 
		return strUtil.toStrJoinComma(st);
	}


	public static Map from(String t) {
		
		return 	AtiJson.fromJson (t);
	}


	public static Map reduce(Map req, Set<String> cols) {
		 Map r=new HashMap ();
		 for (String col : cols) {
			 if(req.get(col)!=null)
			r.put(col, req.get(col));
		}
		return r;
	}

}
